import { request } from "@/utils/request";

export interface Banner {
  url: string;
  _id: string;
  target: string;
  picurl: string;
  appid?: string;
  path?: string;
}
export interface Random {
  nickname: string;
  _id: string;
  tabs: string[];
  smallPicurl: string;
  score: string;
  description: string;
  classid: string;
}
export interface News {
  author: string;
  _id: string;
  publish_date: number;
  select: boolean;
  title: string;
  view_count: number;
}

export const apiGetBanner = () => {
  return request<Banner[]>("/homeBanner", {
    catch: () => {
      return {
        data: [
          {
            _id: "111",
            picurl:
              "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            url: "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            target: "self",
          },
          {
            _id: "222",
            picurl:
              "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            url: "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            target: "self",
          },
          {
            _id: "333",
            picurl:
              "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            url: "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            target: "self",
          },
        ],
        errCode: 0,
        errMsg: "",
      };
    },
  });
};
export const apiGetRandomWall = () => {
  return request<Random[]>("/randomWall", {
    catch: () => {
      return {
        data: Array(8)
          .fill({
            nickname: "全部",
            _id: "1234567",
            classid: "1234567",
            smallPicurl:
              "https://img2.baidu.com/it/u=3209353042,356122753&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            description: `${Date.now()}`,
            tabs: ["好", "差"],
            score: "5",
          })
          .map((item) => ({ ...item, _id: item._id + Math.random() })),
        errCode: 0,
        errMsg: "",
      };
    },
  });
};
export const apiGetWallNewsList = (data: { select?: boolean } = {}) => {
  return request<News[]>("/wallNewsList", {
    data,
    catch: () => {
      return {
        data: [
          {
            author: "全部",
            _id: "111",
            select: true,
            title: "1111111",
            publish_date: Date.now(),
            view_count: 5,
          },
          {
            author: "全部",
            _id: "222",
            select: true,
            title: "222222",
            publish_date: Date.now(),
            view_count: 5,
          },
        ],
        errCode: 0,
        errMsg: "",
      };
    },
  });
};
